﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsApp1.Common;

namespace WinFormsApp1.TongShiWei.PigData
{
    public partial class UpWhitePork : UIForm
    {
        public UpWhitePork(int pid = 0)
        {
            InitializeComponent();
            GetWhitePorkData(pid);
         }
        public async void GetWhitePorkData(int pid)
        {
            List<WhiteWeighing> whiteWeighings = new List<WhiteWeighing>();
            var res = await HttpClientHelper.RequestUrl<WhiteWeighing, ApiResult<List<WhiteWeighing>>>(URLCommon.Url2, "/TSW/ShowWhitePorkData", HttpClientHelper.MethodType.GET);
            if (res.Code > 0)
            {
                var data = res.Data.FirstOrDefault(x => x.WhiteWeighingId == pid);
                if (data != null)
                {
                    uiTextBox1.Text = data.SlaughterNo;
                    uiTextBox7.Text = data.GoodsMinute;
                    uiTextBox2.Text = data.GrossWeight.ToString();
                    uiTextBox5.Text = data.NetWeight.ToString();
                    uiTextBox4.Text = data.WeighingNum.ToString();
                    uiTextBox3.Text = data.DeductionName;
                    uiTextBox8.Text = data.WhiteWeighingDesc;
                    dateTimePicker1.Text = data.WhiteWeighingDate.ToString();
                }
            }
        }
        private void uiButton3_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
        /// <summary>
        /// 白条称重明细表
        /// </summary>
        public class WhiteWeighing
        {
            /// <summary>
            /// 白条明细表ID
            /// </summary>
            public int WhiteWeighingId { get; set; }
            /// <summary>
            /// 仓库
            /// </summary>
            public string DepotName { get; set; }
            /// <summary>
            /// 屠宰编号
            /// </summary>
            public string SlaughterNo { get; set; }
            /// <summary>
            /// 商品代号
            /// </summary>
            public string GoodsMinute { get; set; }
            /// <summary>
            /// 称重时间
            /// </summary>
            public DateTime WhiteWeighingDate { get; set; }
            /// <summary>
            /// 皮重
            /// </summary>
            public double SkinWeight { get; set; }
            /// <summary>
            /// 毛重
            /// </summary>
            public double GrossWeight { get; set; }
            /// <summary>
            /// 净重
            /// </summary>
            public double NetWeight { get; set; }
            /// <summary>
            /// 扣减项
            /// </summary>
            public string DeductionName { get; set; }
            /// <summary>
            /// 备注
            /// </summary>
            public string WhiteWeighingDesc { get; set; }
            /// <summary>
            /// 数量
            /// </summary>
            public int WeighingNum { get; set; }
            /// <summary>
            /// 划膘编号
            /// </summary>
            public string FattenName { get; set; }
            /// <summary>
            /// 逻辑删除
            /// </summary>
            public bool IsDel { get; set; }
        }
    }
}
